package com.wngbms.netty.seatdemo.comm;

public enum MagicVersion {

    V1((byte) 0b0000, (byte) 4, "V1.0.0")

    ;

    byte type;
    byte bitLen; // 占用的比特位数
    String desc;

    MagicVersion(byte type, byte bitLen, String desc) {
        this.type = type;
        this.bitLen = bitLen;
        this.desc = desc;
    }

    public byte getType() {
        return type;
    }

    public void setType(byte type) {
        this.type = type;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public static MagicVersion find(byte val) {
        MagicVersion[] values = MagicVersion.values();
        for (int i = 0; i < values.length; i++) {
            if (values[i].getType() == val) {
                return values[i];
            }
        }
        return null;
    }

}
